import java.util.Scanner;

public class Main6 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        double[] prices = new double[n];
        for (int i = 0; i < n; i++) {
            prices[i] = in.nextDouble();
        }
        int[] counts = new int[n];
        double total = 0.0;
        while(in.hasNextInt()) {
            int type = in.nextInt();
            int count = in.nextInt();
            if(type == 0) {
                break;
            }
            counts[type - 1] += count;
            total += prices[type - 1] * count;
        }
        for (int i = 0; i < n; i++) {
            System.out.println(counts[i]);
        }
        System.out.printf("%.2f", total);
    }
}
